package com.tyk.bookstore.front.payment.strategy.impl;

import com.tyk.bookstore.front.member.service.MemberApiService;
import com.tyk.bookstore.front.payment.strategy.PayAction;
import com.tyk.bookstore.front.payment.strategy.query.PayQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author tyk
 * @description WeChatPayAction
 */
@Component
@RequiredArgsConstructor
public class WeChatPayAction implements PayAction<PayQuery> {

    private final MemberApiService memberApiService;

    @Override
    public String pay(PayQuery query, Runnable callback) {
        // 扣减会员账户
        memberApiService.deductAmount(query.getPrincipal(), query.getCertificate(), query.getAmount());
        // 执行回调
        callback.run();
        // 微信支付不返回信息
        return "";
    }
}
